webpackJsonp([4],{

/***/ 0:
/***/ (function(module, exports, __webpack_require__) {


window._ = __webpack_require__(2);

/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

/*try {
    window.$ = window.jQuery = require('jquery');

    require('bootstrap-sass');
} catch (e) {}*/

/**
 * We'll load the axios HTTP library which allows us to easily issue requests
 * to our Laravel back-end. This library automatically handles sending the
 * CSRF token as a header based on the value of the "XSRF" token cookie.
 */

window.axios = __webpack_require__(3);

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

/**
 * Next we will register the CSRF Token as a common header with Axios so that
 * all outgoing HTTP requests automatically have it attached. This is just
 * a simple convenience so we don't have to attach every token manually.
 */

var token = document.head.querySelector('meta[name="csrf-token"]');

if (token) {
  window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
  console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */

// import Echo from 'laravel-echo'

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({
//     broadcaster: 'pusher',
//     key: 'your-pusher-key'
// });

/***/ }),

/***/ 1:
/***/ (function(module, exports) {

//设置toastr选项
toastr.options = {
    "closeButton": true,
    "debug": false,
    "progressBar": true,
    "preventDuplicates": false,
    "positionClass": "toast-top-right",
    "onclick": null,
    "showDuration": "400",
    "hideDuration": "1000",
    "timeOut": "1000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
};
window.utils = {
    /**
     *
     * @param data json响应数据
     * @param loadtag 载入标签
     */
    showToastr: function showToastr(data) {
        var loadtag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

        switch (data.status) {
            case 'success':
                toastr.success(data.message, data.title);
                break;
            case 'error':
                toastr.error(data.message, data.title);
                break;
            case 'info':
                toastr.info(data.message, data.title);
                break;
            default:
                toastr.warning(data.message, data.title);
                break;
        }
        if (data.status == 'success') {
            switch (loadtag) {
                case 'reload':
                    utils.reload(data.jumpTime);
                    break;
                case 'goback':
                    utils.goback(data.jumpTime);
                    break;
                case 'go':
                    if (data.url) {
                        utils.redirect(data.url, data.jumpTime);
                    }
                    break;
                default:
                    break;
            }
        }
    },
    bootstraptableOptions: {
        url: '', //请求地址
        method: 'get', //请求方式（*）
        toolbar: '#toolbar', //工具按钮用哪个容器
        striped: true, //是否显示行间隔色
        cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true, //是否显示分页（*）
        sortable: false, //是否启用排序
        sortOrder: "asc", //排序方式
        sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1, //初始化加载第一页，默认第一页
        pageSize: 10, //每页的记录行数（*）
        pageList: [10, 25, 50, 100], //可供选择的每页的行数（*）
        paginationFirstText: "首页",
        paginationPreText: "上一页", //分页条中上一页按钮的图标或文字
        paginationNextText: "下一页", //分页条中下一页按钮的图标或文字
        paginationLastText: "尾页",
        queryParamsType: "", //limit:获取页面偏移量offset和页面大小pageSize,"":获取当前页数pageNumber和页面大小pageSize
        responseHandler: function responseHandler(response) {
            return {
                rows: response.data,
                total: response.total
            };
        },
        search: false, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        contentType: "application/x-www-form-urlencoded",
        strictSearch: true,
        showColumns: true, //是否显示所有的列
        showRefresh: true, //是否显示刷新按钮
        minimumCountColumns: 2, //最少允许的列数
        clickToSelect: true, //是否启用点击选中行
        uniqueId: "no", //每一行的唯一标识，一般为主键列
        showToggle: true, //是否显示详细视图和列表视图的切换按钮
        cardView: false, //是否显示详细视图
        detailView: false, //是否显示父子表
        icons: {
            refresh: 'fa fa-refresh',
            detailOpen: 'fa fa-tasks',
            toggle: 'fa fa-exchange'
        },
        onLoadSuccess: function onLoadSuccess(res) {
            //加载成功时执行
            layer.msg("加载成功", { time: 1000 });
        },
        onLoadError: function onLoadError() {
            //加载失败时执行
            layer.msg("加载数据失败");
        }
    },
    /**
     * 确认框
     * @param url
     * @param data
     * @param title
     * @param content
     */
    confirm: function confirm(url) {
        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var callback = arguments[2];
        var title = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '你确定删除么？';
        var content = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '删除后将无法恢复';

        layer.confirm(content, { icon: 3, title: title }, function (index) {
            axios.post(url, data).then(function (response) {
                if (callback) {
                    callback.call(null, response, data);
                } else {
                    utils.showToastr(response.data, 'go');
                }
            }).catch(function (error) {
                if (error.response) {
                    utils.showToastr({
                        'status': 'error',
                        'title': error.response.title,
                        'message': error.response.message
                    });
                } else if (error.request) {
                    console.log(error.request);
                } else {
                    utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
                }
            });

            layer.close(index);
        });
    },
    /**
     * 页面跳转，重定向
     * @param url 跳转链接
     * @param times 等待时间
     */
    redirect: function redirect(url) {
        var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;

        if (times > 0) {
            setTimeout(function () {
                window.location.href = url;
            }, times);
        } else {
            window.location.href = url;
        }
    },
    /**
     * 页面刷新
     * @param times 等待时间
     */
    reload: function reload() {
        var times = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;

        if (times) {
            setTimeout(function () {
                window.location.reload();
            }, times);
        } else {
            window.location.reload();
        }
    },
    /**
     * 页面返回
     * @param times 等待时间
     */
    goback: function goback() {
        var times = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;

        if (times) {
            setTimeout(function () {
                window.history.back(-1);
            }, times);
        } else {
            window.history.back(-1);
        }
    },
    /**
     * 异步post请求
     * @param posturl
     * @param data
     * @param callback
     */
    ajaxPost: function ajaxPost(posturl) {
        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var callback = arguments[2];

        axios.post(posturl, data).then(function (response) {
            if (callback) {
                callback.call(null, response, data);
            } else {
                utils.showToastr(response.data, 'go');
            }
        }).catch(function (error) {
            if (error.response) {
                utils.showToastr({
                    'status': 'error',
                    'title': error.response.title,
                    'message': error.response.message
                });
            } else if (error.request) {
                console.log(error.request);
            } else {
                utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
            }
        });
    },
    /**
     * 异步get请求
     * @param posturl
     * @param data
     * @param callback
     */
    ajaxGet: function ajaxGet(geturl) {
        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var callback = arguments[2];

        axios.get(geturl, {
            params: data
        }).then(function (response) {
            if (callback) {
                callback.call(null, response, data);
            } else {
                utils.showToastr(response.data, 'go');
            }
        }).catch(function (error) {
            if (error.response) {
                utils.showToastr({
                    'status': 'error',
                    'title': error.response.title,
                    'message': error.response.message
                });
            } else if (error.request) {
                console.log(error.request);
            } else {
                utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
            }
        });
    },
    /**
     * 异步提交表单
     * @param posturl
     * @param data
     */
    ajaxSubmitForm: function ajaxSubmitForm(form, posturl) {
        var otherData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
        var callback = arguments[3];

        var params = $(form).serializeArray();
        var formData = {};
        for (x in params) {
            formData[params[x].name] = params[x].value;
        }
        var postdata = _.merge(formData, otherData);
        posturl = posturl ? posturl : $(form).attr('action');
        if (!posturl) {
            console.log('表单提交路径为空');
        }
        axios.post(posturl, postdata).then(function (response) {
            if (callback) {
                callback.call(null, response, postdata);
            } else {
                utils.showToastr(response.data, 'go');
            }
        }).catch(function (error) {
            if (error.response) {
                utils.showToastr({
                    'status': 'error',
                    'title': error.response.title,
                    'message': error.response.message
                });
            } else if (error.request) {
                console.log(error.request);
            } else {
                utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
            }
        });
    }
};

/***/ }),

/***/ 51:
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(52);


/***/ }),

/***/ 52:
/***/ (function(module, exports, __webpack_require__) {

/**
 * 载入项目引导文件
 */
__webpack_require__(0);

/**
 * 载入自定义工具
 */

__webpack_require__(1);

var box = void 0; //弹窗对象
var loadbox; //loading对象
var zTree; //zTree对象

$(document).ready(function () {
    var tableOptions = utils.bootstraptableOptions;
    //请求后台的URL
    tableOptions.url = page_params.url_list;
    //搜索参数
    tableOptions.queryParams = function (params) {
        //传递参数（*）
        //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
        var temp = {
            //limit: params.limit,   //页面大小
            //offset: params.offset,
            pageSize: params.pageSize,
            page: params.pageNumber,
            subscribe_scene: $("#subscribe_scene").val(),
            openid: $("#openid").val(),
            sex: $("#sex").val(),
            keyword: $("#keyword").val()
        };
        return temp;
    };
    tableOptions.rowStyle = function (row, index) {
        var style = "";
        if (row.is_lock) {
            style = 'danger';
        }
        return { classes: style };
    };
    tableOptions.columns = [{ field: 'checkbox', checkbox: 'true' }, { field: 'user_id', title: '#' }, { field: 'openid', title: 'OPENID' }, { field: 'nickname', title: '昵称' }, { field: 'sex_name', title: '性别' }, {
        field: 'headimgurl', title: '头像',
        formatter: function formatter(value, row, index) {
            if (value) {
                return '<img alt="image" class="img-circle img-sm" src="' + value + '">';
            }
        }
    }, { field: 'language', title: '语言', visible: false }, { field: 'country', title: '国家', visible: false }, { field: 'province', title: '省份', visible: false }, { field: 'city', title: '城市', visible: false }, { field: 'first_subscribe_time', title: '首次关注时间', visible: false }, { field: 'remark', title: '备注' }, { field: 'subscribe_scene_name', title: '关注场景', visible: false }, {
        field: 'tagname_list', title: '标签',
        formatter: function formatter(value, row, index) {
            var tagnames = [];
            if (value) {
                _.each(value, function (tagname) {
                    tagnames.push('<span class="label label-warning">' + tagname + '</span>');
                });
            }
            return tagnames.join("\r\n");
        }
    }, {
        field: 'subscribe', title: '是否关注',
        formatter: function formatter(value, row, index) {
            if (value == 1) {
                return '<span class="label label-info">已关注</span>';
            } else {
                return '<span class="label label-warning">未关注</span>';
            }
        }
    }, {
        field: 'is_lock', title: '是否拉黑',
        formatter: function formatter(value, row, index) {
            if (value == 1) {
                return '<span class="label label-danger">已拉黑</span>';
            } else {
                return '<span class="label label-success">正常</span>';
            }
        }
    }, {
        field: 'operate',
        title: '操作',
        formatter: function formatter(value, row, index) {
            var buttons = [];
            if (page_params.url_setremark) {
                buttons.push('<button class="btn btn-primary btn-sm btn-setremark"><i class="fa fa-book"></i> 备注</button>');
            }
            if (page_params.url_settag) {
                buttons.push('<button class="btn btn-primary btn-sm btn-settag"><i class="fa fa-tag"></i> 设标签</button>');
            }
            if (page_params.url_setblack) {
                if (row.is_lock) {
                    buttons.push('<button class="btn btn-success btn-sm btn-setblack"><i class="fa fa-unlock"></i> 恢复</button>');
                } else {
                    buttons.push('<button class="btn btn-danger btn-sm btn-setblack"><i class="fa fa-lock"></i> 拉黑</button>');
                }
            }
            return buttons.join("\r\n");
        }, //自定义方法，添加操作按钮
        events: {
            'click .btn-setremark': function clickBtnSetremark(e, value, row, index) {
                $("#box-remark form").resetForm();
                $('#box-remark form').attr('action', page_params.url_setremark);
                $("#box-remark input[name='openid']").val(row.openid);
                $("#box-remark input[name='remark']").val(row.remark);
                box = layer.open({
                    type: 1,
                    title: '设置备注',
                    anim: 2,
                    shadeClose: true, //开启遮罩关闭
                    skin: 'layui-layer-molv', //加上边框
                    area: ['500px', '200px'], //宽高
                    content: $('#box-remark')
                });
            },
            'click .btn-settag': function clickBtnSettag(e, value, row, index) {
                $("#box-tag form").resetForm();
                $("#box-tag form").attr('action', page_params.url_settag);
                $("#box-tag input[name='openids']").val(row.openid);
                //取消选中
                zTree.checkAllNodes(false);
                //设置部分选中
                if (row.tagid_list.length > 0) {
                    _.each(row.tagid_list, function (tagid, i) {
                        var node = zTree.getNodeByParam("wx_tag_id", tagid);
                        if (node) {
                            zTree.checkNode(node, true, true);
                        }
                    });
                }

                box = layer.open({
                    type: 1,
                    title: '设置标签',
                    anim: 2,
                    shadeClose: true, //开启遮罩关闭
                    skin: 'layui-layer-molv', //加上边框
                    area: ['500px', '400px'], //宽高
                    content: $('#box-tag')
                });
                return false;
            },
            'click .btn-setblack': function clickBtnSetblack(e, value, row, index) {
                var openids = [];
                openids.push(row.openid);
                setBlack(openids, !row.is_lock);
            }
        }
    }];
    var table = $("#table").bootstrapTable(tableOptions);
    //设置zetree
    var setting = {
        check: {
            enable: true
        },
        data: {
            key: {
                name: 'tag_name'
            },
            simpleData: {
                idKey: 'tag_id',
                pIdKey: 'parent_id',
                rootPId: 0,
                enable: true
            }
        }
    };
    $.fn.zTree.init($("#treeTag"), setting, page_params.data_tag);
    zTree = $.fn.zTree.getZTreeObj("treeTag");
    zTree.expandAll(true);
    //搜索按钮
    $("#btn-search").on('click', function () {
        table.bootstrapTable('refresh');
    });
    //设置黑名单
    function setBlack(openids, is_lock) {
        var title = '';
        var remark = '';
        if (is_lock) {
            title = '确认加入黑名单?';
            remark = '加入黑名单后，你将无法接收该用户发来的消息，且该用户无法接收公众号发出的消息，无法参与留言和赞赏';
        } else {
            title = '确定恢复用户？';
            remark = '恢复用户后将恢复所有正常功能';
        }
        utils.confirm(page_params.url_setblack, {
            openids: openids, is_lock: is_lock
        }, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                table.bootstrapTable('refresh');
            }
        }, title, remark);
    }
    //批量添加黑名单
    $("#btn-addblack").on('click', function () {
        var checkedlist = table.bootstrapTable('getSelections');
        if (checkedlist.length <= 0) {
            layer.alert('请选择打标签的用户', { title: '友情提示', icon: 2 });
        }
        var openids = [];
        $.each(checkedlist, function (i, user) {
            openids.push(user.openid);
        });
        setBlack(openids, 1);
    });
    //提交表单
    $("#box-remark .btn-sub").on('click', function () {
        utils.ajaxSubmitForm($("#box-remark form"), '', {}, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                layer.close(box);
                table.bootstrapTable('refresh');
            }
        });
    });
    //批量打标签
    $("#btn-addtag").on('click', function () {
        var checkedlist = $('#table').bootstrapTable('getSelections');
        if (checkedlist.length <= 0) {
            layer.alert('请选择打标签的用户', { title: '友情提示', icon: 2 });
            return false;
        }
        var openids = [];
        $.each(checkedlist, function (i, user) {
            openids.push(user.openid);
        });
        $("#box-tag form").resetForm();
        $("#box-tag form").attr('action', page_params.url_addtag);
        $("#box-tag input[name='openids']").val(openids.join(','));
        //取消选中
        zTree.checkAllNodes(false);
        box = layer.open({
            type: 1,
            title: '批量打标签',
            anim: 2,
            shadeClose: true, //开启遮罩关闭
            skin: 'layui-layer-molv', //加上边框
            area: ['500px', '400px'], //宽高
            content: $('#box-tag')
        });
    });
    //标签保存
    $("#box-tag .btn-sub").on('click', function () {
        //已选权限
        //var checkedNode = $("#jstree").jstree('get_checked');
        var tagIds = [];
        var zTree = $.fn.zTree.getZTreeObj("treeTag");
        var nodes = zTree.getCheckedNodes(true);
        $.each(nodes, function (n, value) {
            tagIds.push(value.wx_tag_id);
        });
        utils.ajaxSubmitForm($("#box-tag form"), '', { tagIds: tagIds }, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                layer.close(box);
                table.bootstrapTable('refresh');
            }
        });
    });
    //同步用户
    $("#btn-sync").on('click', function () {
        utils.confirm(page_params.url_sync, {}, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                table.bootstrapTable('refresh');
            }
        }, '你确定同步所有用户数据么？', '该同步过程可能花费大量时间');
    });
    //同步黑名单
    $("#btn-syncblack").on('click', function () {
        utils.confirm(page_params.url_syncblack, {}, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                table.bootstrapTable('refresh');
            }
        }, '你确定黑名单用户么？', '该同步过程可能花费大量时间');
    });
});

/***/ })

},[51]);